package com.sk.bilibili.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.sk.bilibili.bean.FocusGroup;
import com.sk.bilibili.other.R;
import com.sk.bilibili.service.FocusGroupService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpSession;
import java.util.List;

/**
 * @author 邵康
 * @date 2021/11/26 21:00
 */
@Api(tags = "关注分组管理")
@CrossOrigin
@RestController
@RequestMapping("/focusGroup")
public class FocusGroupController {

    @Autowired
    private FocusGroupService focusGroupService;

    @ApiOperation("添加关注分组  只有名称是必要的")
    @PostMapping("/add")
    public R<Void> add(@RequestBody FocusGroup focusGroup) {
        return focusGroupService.add(focusGroup);
    }

    @ApiOperation("删除分组  并把里面的人放到默认分组")
    @GetMapping("/delete")
    public R<Void> delete(Integer id) {
        return focusGroupService.delete(id);
    }

    @ApiOperation("更新分组  只能更新名字  id必须")
    @PostMapping("/update")
    public R<Void> update(@RequestBody FocusGroup focusGroup) {
        return focusGroupService.update(focusGroup);
    }

    @ApiOperation("获取所有分组")
    @PostMapping("/getAll")
    public R<List<FocusGroup>> getAll() {
        return focusGroupService.getAll();
    }

    @ApiOperation("pageSearch")
    @GetMapping("/page")
    public R<IPage<FocusGroup>> page(@RequestParam(defaultValue = "1") Integer page,
                                     @RequestParam(defaultValue = "10") Integer size) {
        return focusGroupService.page(page, size);
    }

}
